<template>
  <div class="detailbar">
    <nav-bar>
      <div slot="left">
        <img src="~assets/img/common/back.svg" alt="" />
      </div>
      <div slot="center" class="title">
        <div
          v-for="(item, index) in titles"
          :class="{ active: index == currentIndex }"
          @click="titleClick(index)"
          @scroll="titleScroll(index)"
        >
          {{ item }}
        </div>
      </div>
    </nav-bar>
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar";
export default {
  name: "detailBar",
  data() {
    return {
      titles: ["商品", "参数", "评论", "推荐"],
      currentIndex: 0,
    };
  },
  components: {
    NavBar,
  },
  methods: {
    titleClick(index) {
      this.currentIndex = index;
      this.$emit('titleClick',index)
    },
  },
};
</script>

<style  scoped>
.detailbar {
  position: relative;
  z-index: 21;
  background-color: white;
}
.title {
  display: flex;
  font-size: 14px;
}
.title > div {
  flex: 1;
}
.active {
  color: var(--color-high-text);
}
</style>
